package com.lyw.util;

import java.util.ArrayList;
import java.util.List;

public class StringUtil {

    /**
     * String转Int
     * @param str
     * @return
     */
    public static int StringToInt(String str) {
        int result = 0;
        try {
            result = Integer.parseInt(str);
        } catch (NumberFormatException e) {
            result = 0;
            //e.printStackTrace();
        }
        return result;
    }
    /**
     * 获取盐值（随机字符串）
     * @param length
     * @return
     */
    public static String getRandomString(int length) {
        String base = "1a2b3c";

        return base;
    }

    public static List<String> splitProperties (String properties){
        List<String> options = new ArrayList<String>();
        String option = null;
        String[] strings = properties.split(",");
        for (String string : strings) {
            if(!"0".equals(string)){
                option = string.charAt(3)+"";
                options.add(option);

            }
        }
        return options;

    }
    /**
     * String转float
     * @param str
     * @return
     */
    public static float strToFlo(String str) {
        float i = 0;
        try {
            i = Integer.parseInt(str);
        } catch (Exception e) {
        }
        return i;
    }
}
